using WatchDog;
using WatchDog.src.Enums;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddHttpContextAccessor();

builder.Services.AddOutputCache();
//builder.Services.AddWatchDogServices();
builder.Services.AddWatchDogServices(opt =>
{
    opt.IsAutoClear = true;


    opt.DbDriverOption = WatchDogDbDriverEnum.MSSQL;
    opt.SetExternalDbConnString = "Server=.;Database=Repeaterdb_WatchDog;User Id=sa;Password=1;";

    //opt.DbDriverOption = WatchDogDbDriverEnum.MySql;
    //opt.SetExternalDbConnString = "Server=127.0.0.1;Port=3306;Database=Repeaterdb_WatchDog;Uid=root;Pwd=1;";



    //opt.DbDriverOption = WatchDogDbDriverEnum.Mongo;
    //opt.SetExternalDbConnString = "mongodb://localhost:27017/";

    //opt.DbDriverOption = WatchDogDbDriverEnum.PostgreSql;
    //opt.SetExternalDbConnString = "Host=127.0.0.1;Port=5432;Database=Repeaterdb_WatchDog2;Username=e4glet;Password=postgres;";
});

var app = builder.Build();

app.UseWatchDogExceptionLogger();
app.MapGet("api/user", (HttpResponse response) => "User");
app.MapGet("api/userRole", (HttpResponse response) => "UserRole");
// Configure the HTTP request pipeline.
app.UseSwagger();
app.UseSwaggerUI();

app.UseHttpsRedirection();

app.UseAuthorization();
app.UseOutputCache();
app.UseWatchDog(conf =>
{
    conf.WatchPageUsername = "admin";
    conf.WatchPagePassword = "1";
    conf.Blacklist = "/auth, api/user";
    conf.UseOutputCache = true;
});

app.MapControllers();

app.Run();
